import request from '@/utils/request'

// 创建编号规则
export function createCode(data) {
  return request({
    url: '/system/code/create',
    method: 'post',
    data: data
  })
}

// 更新编号规则
export function updateCode(data) {
  return request({
    url: '/system/code/update',
    method: 'put',
    data: data
  })
}

// 删除编号规则
export function deleteCode(id) {
  return request({
    url: '/system/code/delete?id=' + id,
    method: 'delete'
  })
}

// 获得编号规则
export function getCode(id) {
  return request({
    url: '/system/code/get?id=' + id,
    method: 'get'
  })
}

// 获得编号规则分页
export function getCodePage(query) {
  return request({
    url: '/system/code/page',
    method: 'get',
    params: query
  })
}

// 导出编号规则 Excel
export function exportCodeExcel(query) {
  return request({
    url: '/system/code/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 生成编号
export function genCode(code) {
  return request({
    url: '/system/code/gen?code=' + code,
    method: 'get'
  })
}
